<template>
  <el-card
    :body-style="{
      padding: '0px',
      width: '100%',
      height: '100%',
      display: 'flex',
      'flex-direction': 'column',
      'justify-content': 'flex-start',
      'align-items': 'center',
      position: 'relative',
    }"
    shadow="hover"
    @mouseenter.native="isHover = true"
    @mouseleave.native="isHover = false"
  >
    <transition name="el-fade-in">
      <div class="right_top_bar" v-show="isHover">
        <slot></slot>
      </div>
    </transition>

    <div class="img_container">
      <!-- <img :src="course.image" class="image" /> -->
      <el-image class="image" :src="course.image" lazy>
        <div slot="placeholder" class="image-slot">
          加载中<span class="dot">...</span>
        </div>
      </el-image>
    </div>
    <div class="detail">
      <span>{{ course.name }}</span>
      <div class="bottom">
        <span>{{ course.teacher }}</span>
        <el-divider direction="vertical"></el-divider>
        <span>{{ course.views }}<i class="el-icon-user"></i></span>
      </div>
    </div>
  </el-card>
</template>

<script>
export default {
  name: "CourserBox",
  props: ["course"],
  data() {
    return {
      isHover: false,
    };
  },
};
</script>

<style lang="less" scoped>
.el-card {
  height: 270px;
  border-radius: 15px;
  position: relative;
  .right_top_bar {
    position: absolute;
    top: 0;
    right: 0;
    overflow: hidden;
    border-bottom-left-radius: 35px;
    z-index: 100;
  }
  .img_container {
    height: 60%;
    width: 100%;
    margin-bottom: 10px;
    overflow: hidden;
    .image {
      width: 100%;
      height: 100%;
      transition: all 0.3s ease-in-out;
    }
  }

  .detail {
    height: 30%;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    span:nth-child(1) {
      margin-left: 20px;
      align-self: flex-start;
    }
    .bottom {
      width: 100%;
      display: flex;
      color: #ccc;
      font-size: 12px;
      flex-direction: row;
      justify-content: flex-end;
      align-items: center;
      span:nth-child(3) {
        margin-right: 20px;
      }
    }
  }
}
.image-slot {
  text-align: center;
  line-height: 162px;
  font-size: 2em;
  background-color: #eee;
}
</style>